<?php $path = base_url().'public/frontend/';?>
<div class="product-details"><!--product-details-->
    <div class="col-sm-5">
        <div class="view-product">
            <img src="<?php
            if (strpos($products[0]['url_image'], '//'))
                echo $products[0]['url_image'];
            else echo base_url().'public/images/'.$products[0]['url_image']; ?>" alt="" />
<!--            <h3>ZOOM</h3>-->
        </div>


    </div>
    <div class="col-sm-7">
        <div class="product-information"><!--/product-information-->
            <h2><?php echo $products[0]["product_name"] ?></h2>
            <p>Web ID: <?php echo $products[0]["product_id"] ?></p>
            <input hidden="hidden" id="pid" value="<?php echo $products[0]["product_id"] ?>">
                                    <?php if(!$products[0]['new_price']){?>
                                        <span>$<?php echo $products[0]["unit_price"] ?></span>
                                    <?php } elseif ($products[0]['new_price']){?>
                                    <del style="color: #FE980F;
                                        font-family: 'Roboto', sans-serif;
                                        font-size: 24px;
                                        font-weight: 700;">$<?php echo $products[0]["unit_price"] ?></del>
                                    <h2 style="color: #FE980F;
                                        font-family: 'Roboto', sans-serif;
                                        font-size: 24px;
                                        font-weight: 700;">$<?php echo $products[0]["new_price"] ?><span><span> </span><label>Quantity:</label>
									<input id="quantity" type="text" style="width: 30px;"/>
									<button type="button" id="addCart" class="btn btn-fefault cart">
                                        <i class="fa fa-shopping-cart"></i>
                                        Add to cart
                                    </button></span></h2>
                                    <?php } ?>
            <p><b>Availability:</b> <?php if($products[0]["quantity_remaining"] ==0) {echo "Out of Stock";}
                else{
                    echo $products[0]["quantity_remaining"]." Units In Stock";
                }?></p>
        </div><!--/product-information-->
    </div>
</div><!--/product-details-->

<div class="category-tab shop-details-tab"><!--category-tab-->
    <div class="col-sm-12">
        <ul class="nav nav-tabs">
            <li><a href="#details" data-toggle="tab">Details</a></li>
            <li class="active"><a href="#reviews" data-toggle="tab">Reviews (5)</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane fade" id="details" >
            <p style="padding: 20px"><?php echo $products[0]["description"] ?></p>
        </div>

        <div class="tab-pane fade active in" id="reviews" >
            <div class="col-sm-12">
                <ul>
                    <li><a href=""><i class="fa fa-user"></i>EUGEN</a></li>
                    <li><a href=""><i class="fa fa-clock-o"></i>12:41 PM</a></li>
                    <li><a href=""><i class="fa fa-calendar-o"></i>31 DEC 2014</a></li>
                </ul>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
                <p><b>Write Your Review</b></p>

                <form action="#">
										<span>
											<input type="text" placeholder="Your Name"/>
											<input type="email" placeholder="Email Address"/>
										</span>
                    <textarea name="" ></textarea>
                    <button type="button" class="btn btn-default pull-right">
                        Submit
                    </button>
                </form>
            </div>
        </div>

    </div>
</div><!--/category-tab-->

<script>
    $('#addCart').click(function(){
        quantity = $('#quantity').val();
        pid = $('#pid').val();
        $.post('<?php echo base_url() ;?>frontend/purchase/add_cart',{
            pid : pid,
            quantity : quantity
        }).done(function(data){
            if (parseInt(data) == 1) location.href= '<?php echo base_url() ;?>frontend/purchase/cart';
            else if(parseInt(data) == 2){
                alert("Product not enough in stock");
            }
            else alert('Please login first');
        })
    })
</script>
